<?php

class Bizprofile_Widgets_Partnerlist_Widget extends Tomato_Widget 
{
	protected function _prepareShow() 
	{
		$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
		
		$purl = $params['module'] . "_" . strtolower($params['controller']) . "_" . str_replace("-","_",$params['action']);
		$this->_view->assign('purl', $purl);
		
		if($params['module'] == 'bizprofile'){
			$conn = Tomato_Db_Connection::factory()->getMasterConnection();
			
			$auth = Zend_Auth::getInstance();
			if ($auth->hasIdentity()) {
				$user = $auth->getIdentity();
				
				$partnerDao = Tomato_Model_Dao_Factory::getInstance()->setModule("bizprofile")->getPartnerDao();
				$partnerDao->setDbConnection($conn);
				
				$partners = $partnerDao->listPartner($user->enterprise->id);
				if ($partners != null)
					$this->_view->assign('partners', $partners);
			}
		}
	}
	
	protected function _prepareConfig()
	{
		
	}
}
